package org.snusmumr.android.media;

import org.snusmumr.android.media.Constants.ImportExportTask;

import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;

public class SettingsActivity extends PreferenceActivity {
	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setPreferenceScreen(createPreferenceHierarchy());
    }

    private PreferenceScreen createPreferenceHierarchy() {
        // Root
        PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);

        // Inline preferences
        PreferenceCategory impExpCategory = new PreferenceCategory(this);
        impExpCategory.setTitle(R.string.settings_imp_ext_category_title);
        root.addPreference(impExpCategory);
        
        // Export
        PreferenceScreen exportPref = getPreferenceManager().createPreferenceScreen(this);
        Intent intent = new Intent(this, ImportExportActivity.class);
        intent.putExtra(Constants.KEY_TASK_TYPE, ImportExportTask.Export);
        intent.putExtra(Constants.KEY_PATH, "media_catalog_export.csv");
		exportPref.setIntent(intent);
        exportPref.setTitle(R.string.settings_export_title);
        exportPref.setSummary(R.string.settings_export_summary);
        impExpCategory.addPreference(exportPref);
        
        // Import
        PreferenceScreen importPref = getPreferenceManager().createPreferenceScreen(this);
        intent = new Intent(this, ImportExportActivity.class);
        intent.putExtra(Constants.KEY_TASK_TYPE, ImportExportTask.Import);
        intent.putExtra(Constants.KEY_PATH, "media_catalog_export.csv");
        importPref.setIntent(intent);
        importPref.setTitle(R.string.settings_import_title);
        importPref.setSummary(R.string.settings_import_summary);
        impExpCategory.addPreference(importPref);

        return root;
    }

}
